﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


    class SignedInt
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter signed int: ");
            int decimalNumber = short.Parse(Console.ReadLine());
            int bit = 0;
            List<int> binary=new List<int>();
            string result = " ";
            
      
            if (decimalNumber >= 0)
            {
                while (decimalNumber > 0)
                {
                    bit = decimalNumber % 2;
                    decimalNumber = decimalNumber / 2;
                    binary.Add(bit);
                }
                binary.Reverse();
                for (int i = 0; i < binary.Count; i++)
                {
                    result = result + binary[i];
                }
                    while (result.Length % 16 != 0)
                    {
                        result = "0" + result;
                    }
            }
            
            else
            {
                decimalNumber = Math.Abs(decimalNumber)-1;            
                while (decimalNumber > 0)
                {
                    bit = decimalNumber % 2;
                    decimalNumber = decimalNumber / 2;
                    binary.Add(bit);
                }
                binary.Reverse();
                for (int i = 0; i < binary.Count; i++)
                {
                    if (binary[i] == 0)
                    {
                        result = result + "1";
                    }
                    else
                    {
                        result = result + "0";
                    }
                }
                while (result.Length % 16 != 0)
                {
                    result = "1" + result;
                }
            }

            Console.Write("Result: ");           
            Console.WriteLine(result);

            
        }
    }

